<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<title>Developer Interface — Requests 2.3.0 documentation</title>
<link href="_static/flasky.css" rel="stylesheet" type="text/css"/>
<link href="_static/pygments.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '2.3.0',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
<script src="_static/jquery.js" type="text/javascript"></script>
<script src="_static/underscore.js" type="text/javascript"></script>
<script src="_static/doctools.js" type="text/javascript"></script>
<link href="index.html" rel="top" title="Requests 2.3.0 documentation"/>
<link href="dev/philosophy.html" rel="next" title="Development Philosophy"/>
<link href="community/updates.html" rel="prev" title="Community Updates"/>
<meta content="width=device-width, initial-scale=0.9, maximum-scale=0.9" name="viewport"/>
<script src="https://gumroad.com/js/gumroad.js" type="text/javascript"></script>
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a accesskey="I" href="genindex.html" title="General Index">index</a></li>
<li class="right">
<a href="py-modindex.html" title="Python Module Index">modules</a> |</li>
<li class="right">
<a accesskey="N" href="dev/philosophy.html" title="Development Philosophy">next</a> |</li>
<li class="right">
<a accesskey="P" href="community/updates.html" title="Community Updates">previous</a> |</li>
<li><a href="index.html">Requests 2.3.0 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-requests">
<span id="developer-interface"></span><span id="api"></span><h1><a name="//apple_ref/cpp/Module/requests"></a>Developer Interface<a class="headerlink" href="#module-requests" title="Permalink to this headline">¶</a></h1>
<p>This part of the documentation covers all the interfaces of Requests. For
parts where Requests depends on external libraries, we document the most
important right here and provide links to the canonical documentation.</p>
<div class="section" id="main-interface">
<h2>Main Interface<a class="headerlink" href="#main-interface" title="Permalink to this headline">¶</a></h2>
<p>All of Requests’ functionality can be accessed by these 7 methods.
They all return an instance of the <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<dl class="function">
<dt id="requests.request"><a name="//apple_ref/cpp/Function/requests.request"></a>
<tt class="descclassname">requests.</tt><tt class="descname">request</tt><big>(</big><em>method</em>, <em>url</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.request" title="Permalink to this definition">¶</a></dt>
<dd><p>Constructs and sends a <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.
Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>method</strong> – method for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>params</strong> – (optional) Dictionary or bytes to be sent in the query string for the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>data</strong> – (optional) Dictionary, bytes, or file-like object to send in the body of the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>headers</strong> – (optional) Dictionary of HTTP Headers to send with the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>cookies</strong> – (optional) Dict or CookieJar object to send with the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>files</strong> – (optional) Dictionary of ‘name’: file-like-objects (or {‘name’: (‘filename’, fileobj)}) for multipart encoding upload.</li>
<li><strong>auth</strong> – (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.</li>
<li><strong>timeout</strong> – (optional) Float describing the timeout of the request in seconds.</li>
<li><strong>allow_redirects</strong> – (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.</li>
<li><strong>proxies</strong> – (optional) Dictionary mapping protocol to the URL of the proxy.</li>
<li><strong>verify</strong> – (optional) if <tt class="docutils literal"><span class="pre">True</span></tt>, the SSL cert will be verified. A CA_BUNDLE path can also be provided.</li>
<li><strong>stream</strong> – (optional) if <tt class="docutils literal"><span class="pre">False</span></tt>, the response content will be immediately downloaded.</li>
<li><strong>cert</strong> – (optional) if String, path to ssl client cert file (.pem). If Tuple, (‘cert’, ‘key’) pair.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Usage:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">requests</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">req</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="s">'GET'</span><span class="p">,</span> <span class="s">'http://httpbin.org/get'</span><span class="p">)</span>
<span class="go">&lt;Response [200]&gt;</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="requests.head"><a name="//apple_ref/cpp/Function/requests.head"></a>
<tt class="descclassname">requests.</tt><tt class="descname">head</tt><big>(</big><em>url</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.head" title="Permalink to this definition">¶</a></dt>
<dd><p>Sends a HEAD request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="requests.get"><a name="//apple_ref/cpp/Function/requests.get"></a>
<tt class="descclassname">requests.</tt><tt class="descname">get</tt><big>(</big><em>url</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Sends a GET request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="requests.post"><a name="//apple_ref/cpp/Function/requests.post"></a>
<tt class="descclassname">requests.</tt><tt class="descname">post</tt><big>(</big><em>url</em>, <em>data=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.post" title="Permalink to this definition">¶</a></dt>
<dd><p>Sends a POST request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>data</strong> – (optional) Dictionary, bytes, or file-like object to send in the body of the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="requests.put"><a name="//apple_ref/cpp/Function/requests.put"></a>
<tt class="descclassname">requests.</tt><tt class="descname">put</tt><big>(</big><em>url</em>, <em>data=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.put" title="Permalink to this definition">¶</a></dt>
<dd><p>Sends a PUT request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>data</strong> – (optional) Dictionary, bytes, or file-like object to send in the body of the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="requests.patch"><a name="//apple_ref/cpp/Function/requests.patch"></a>
<tt class="descclassname">requests.</tt><tt class="descname">patch</tt><big>(</big><em>url</em>, <em>data=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.patch" title="Permalink to this definition">¶</a></dt>
<dd><p>Sends a PATCH request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>data</strong> – (optional) Dictionary, bytes, or file-like object to send in the body of the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="requests.delete"><a name="//apple_ref/cpp/Function/requests.delete"></a>
<tt class="descclassname">requests.</tt><tt class="descname">delete</tt><big>(</big><em>url</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.delete" title="Permalink to this definition">¶</a></dt>
<dd><p>Sends a DELETE request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<div class="section" id="lower-level-classes">
<h3>Lower-Level Classes<a class="headerlink" href="#lower-level-classes" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="requests.Request"><a name="//apple_ref/cpp/Class/requests.Request"></a>
<em class="property">class </em><tt class="descclassname">requests.</tt><tt class="descname">Request</tt><big>(</big><em>method=None</em>, <em>url=None</em>, <em>headers=None</em>, <em>files=None</em>, <em>data=None</em>, <em>params=None</em>, <em>auth=None</em>, <em>cookies=None</em>, <em>hooks=None</em><big>)</big><a class="headerlink" href="#requests.Request" title="Permalink to this definition">¶</a></dt>
<dd><p>A user-created <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</p>
<p>Used to prepare a <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a>, which is sent to the server.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>method</strong> – HTTP method to use.</li>
<li><strong>url</strong> – URL to send.</li>
<li><strong>headers</strong> – dictionary of headers to send.</li>
<li><strong>files</strong> – dictionary of {filename: fileobject} files to multipart upload.</li>
<li><strong>data</strong> – the body to attach the request. If a dictionary is provided, form-encoding will take place.</li>
<li><strong>params</strong> – dictionary of URL parameters to append to the URL.</li>
<li><strong>auth</strong> – Auth handler or (user, pass) tuple.</li>
<li><strong>cookies</strong> – dictionary or CookieJar of cookies to attach to this request.</li>
<li><strong>hooks</strong> – dictionary of callback hooks, for internal usage.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Usage:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">requests</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">req</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">Request</span><span class="p">(</span><span class="s">'GET'</span><span class="p">,</span> <span class="s">'http://httpbin.org/get'</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">req</span><span class="o">.</span><span class="n">prepare</span><span class="p">()</span>
<span class="go">&lt;PreparedRequest [GET]&gt;</span>
</pre></div>
</div>
<dl class="method">
<dt id="requests.Request.deregister_hook"><a name="//apple_ref/cpp/Method/requests.Request.deregister_hook"></a>
<tt class="descname">deregister_hook</tt><big>(</big><em>event</em>, <em>hook</em><big>)</big><a class="headerlink" href="#requests.Request.deregister_hook" title="Permalink to this definition">¶</a></dt>
<dd><p>Deregister a previously registered hook.
Returns True if the hook existed, False if not.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Request.prepare"><a name="//apple_ref/cpp/Method/requests.Request.prepare"></a>
<tt class="descname">prepare</tt><big>(</big><big>)</big><a class="headerlink" href="#requests.Request.prepare" title="Permalink to this definition">¶</a></dt>
<dd><p>Constructs a <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> for transmission and returns it.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Request.register_hook"><a name="//apple_ref/cpp/Method/requests.Request.register_hook"></a>
<tt class="descname">register_hook</tt><big>(</big><em>event</em>, <em>hook</em><big>)</big><a class="headerlink" href="#requests.Request.register_hook" title="Permalink to this definition">¶</a></dt>
<dd><p>Properly register a hook.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="requests.Response"><a name="//apple_ref/cpp/Class/requests.Response"></a>
<em class="property">class </em><tt class="descclassname">requests.</tt><tt class="descname">Response</tt><a class="headerlink" href="#requests.Response" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object, which contains a
server’s response to an HTTP request.</p>
<dl class="attribute">
<dt id="requests.Response.apparent_encoding"><a name="//apple_ref/cpp/Attribute/requests.Response.apparent_encoding"></a>
<tt class="descname">apparent_encoding</tt><a class="headerlink" href="#requests.Response.apparent_encoding" title="Permalink to this definition">¶</a></dt>
<dd><p>The apparent encoding, provided by the chardet library</p>
</dd></dl>
<dl class="method">
<dt id="requests.Response.close"><a name="//apple_ref/cpp/Method/requests.Response.close"></a>
<tt class="descname">close</tt><big>(</big><big>)</big><a class="headerlink" href="#requests.Response.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Releases the connection back to the pool. Once this method has been
called the underlying <tt class="docutils literal"><span class="pre">raw</span></tt> object must not be accessed again.</p>
<p><em>Note: Should not normally need to be called explicitly.</em></p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Response.content"><a name="//apple_ref/cpp/Attribute/requests.Response.content"></a>
<tt class="descname">content</tt><a class="headerlink" href="#requests.Response.content" title="Permalink to this definition">¶</a></dt>
<dd><p>Content of the response, in bytes.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Response.cookies"><a name="//apple_ref/cpp/Attribute/requests.Response.cookies"></a>
<tt class="descname">cookies</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Response.cookies" title="Permalink to this definition">¶</a></dt>
<dd><p>A CookieJar of Cookies the server sent back.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Response.elapsed"><a name="//apple_ref/cpp/Attribute/requests.Response.elapsed"></a>
<tt class="descname">elapsed</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Response.elapsed" title="Permalink to this definition">¶</a></dt>
<dd><p>The amount of time elapsed between sending the request
and the arrival of the response (as a timedelta)</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Response.encoding"><a name="//apple_ref/cpp/Attribute/requests.Response.encoding"></a>
<tt class="descname">encoding</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Response.encoding" title="Permalink to this definition">¶</a></dt>
<dd><p>Encoding to decode with when accessing r.text.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Response.headers"><a name="//apple_ref/cpp/Attribute/requests.Response.headers"></a>
<tt class="descname">headers</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Response.headers" title="Permalink to this definition">¶</a></dt>
<dd><p>Case-insensitive Dictionary of Response Headers.
For example, <tt class="docutils literal"><span class="pre">headers['content-encoding']</span></tt> will return the
value of a <tt class="docutils literal"><span class="pre">'Content-Encoding'</span></tt> response header.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Response.history"><a name="//apple_ref/cpp/Attribute/requests.Response.history"></a>
<tt class="descname">history</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Response.history" title="Permalink to this definition">¶</a></dt>
<dd><p>A list of <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> objects from
the history of the Request. Any redirect responses will end
up here. The list is sorted from the oldest to the most recent request.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Response.is_redirect"><a name="//apple_ref/cpp/Attribute/requests.Response.is_redirect"></a>
<tt class="descname">is_redirect</tt><a class="headerlink" href="#requests.Response.is_redirect" title="Permalink to this definition">¶</a></dt>
<dd><p>True if this Response is a well-formed HTTP redirect that could have
been processed automatically (by <a class="reference internal" href="#requests.Session.resolve_redirects" title="requests.Session.resolve_redirects"><tt class="xref py py-meth docutils literal"><span class="pre">Session.resolve_redirects()</span></tt></a>).</p>
</dd></dl>
<dl class="method">
<dt id="requests.Response.iter_content"><a name="//apple_ref/cpp/Method/requests.Response.iter_content"></a>
<tt class="descname">iter_content</tt><big>(</big><em>chunk_size=1</em>, <em>decode_unicode=False</em><big>)</big><a class="headerlink" href="#requests.Response.iter_content" title="Permalink to this definition">¶</a></dt>
<dd><p>Iterates over the response data.  When stream=True is set on the
request, this avoids reading the content at once into memory for
large responses.  The chunk size is the number of bytes it should
read into memory.  This is not necessarily the length of each item
returned as decoding can take place.</p>
<p>If decode_unicode is True, content will be decoded using the best
available encoding based on the response.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Response.iter_lines"><a name="//apple_ref/cpp/Method/requests.Response.iter_lines"></a>
<tt class="descname">iter_lines</tt><big>(</big><em>chunk_size=512</em>, <em>decode_unicode=None</em><big>)</big><a class="headerlink" href="#requests.Response.iter_lines" title="Permalink to this definition">¶</a></dt>
<dd><p>Iterates over the response data, one line at a time.  When
stream=True is set on the request, this avoids reading the
content at once into memory for large responses.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Response.json"><a name="//apple_ref/cpp/Method/requests.Response.json"></a>
<tt class="descname">json</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.Response.json" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the json-encoded content of a response, if any.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">json.loads</span></tt> takes.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="requests.Response.links"><a name="//apple_ref/cpp/Attribute/requests.Response.links"></a>
<tt class="descname">links</tt><a class="headerlink" href="#requests.Response.links" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the parsed header links of the response, if any.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Response.raise_for_status"><a name="//apple_ref/cpp/Method/requests.Response.raise_for_status"></a>
<tt class="descname">raise_for_status</tt><big>(</big><big>)</big><a class="headerlink" href="#requests.Response.raise_for_status" title="Permalink to this definition">¶</a></dt>
<dd><p>Raises stored <tt class="xref py py-class docutils literal"><span class="pre">HTTPError</span></tt>, if one occurred.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Response.raw"><a name="//apple_ref/cpp/Attribute/requests.Response.raw"></a>
<tt class="descname">raw</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Response.raw" title="Permalink to this definition">¶</a></dt>
<dd><p>File-like object representation of response (for advanced usage).
Use of <tt class="docutils literal"><span class="pre">raw</span></tt> requires that <tt class="docutils literal"><span class="pre">stream=True</span></tt> be set on the request.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Response.reason"><a name="//apple_ref/cpp/Attribute/requests.Response.reason"></a>
<tt class="descname">reason</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Response.reason" title="Permalink to this definition">¶</a></dt>
<dd><p>Textual reason of responded HTTP Status, e.g. “Not Found” or “OK”.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Response.status_code"><a name="//apple_ref/cpp/Attribute/requests.Response.status_code"></a>
<tt class="descname">status_code</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Response.status_code" title="Permalink to this definition">¶</a></dt>
<dd><p>Integer Code of responded HTTP Status, e.g. 404 or 200.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Response.text"><a name="//apple_ref/cpp/Attribute/requests.Response.text"></a>
<tt class="descname">text</tt><a class="headerlink" href="#requests.Response.text" title="Permalink to this definition">¶</a></dt>
<dd><p>Content of the response, in unicode.</p>
<p>If Response.encoding is None, encoding will be guessed using
<tt class="docutils literal"><span class="pre">chardet</span></tt>.</p>
<p>The encoding of the response content is determined based solely on HTTP
headers, following RFC 2616 to the letter. If you can take advantage of
non-HTTP knowledge to make a better guess at the encoding, you should
set <tt class="docutils literal"><span class="pre">r.encoding</span></tt> appropriately before accessing this property.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Response.url"><a name="//apple_ref/cpp/Attribute/requests.Response.url"></a>
<tt class="descname">url</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Response.url" title="Permalink to this definition">¶</a></dt>
<dd><p>Final URL location of Response.</p>
</dd></dl>
</dd></dl>
</div>
</div>
<div class="section" id="request-sessions">
<h2>Request Sessions<a class="headerlink" href="#request-sessions" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="requests.Session"><a name="//apple_ref/cpp/Class/requests.Session"></a>
<em class="property">class </em><tt class="descclassname">requests.</tt><tt class="descname">Session</tt><a class="headerlink" href="#requests.Session" title="Permalink to this definition">¶</a></dt>
<dd><p>A Requests session.</p>
<p>Provides cookie persistence, connection-pooling, and configuration.</p>
<p>Basic Usage:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">requests</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">Session</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'http://httpbin.org/get'</span><span class="p">)</span>
<span class="go">200</span>
</pre></div>
</div>
<dl class="attribute">
<dt id="requests.Session.auth"><a name="//apple_ref/cpp/Attribute/requests.Session.auth"></a>
<tt class="descname">auth</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Session.auth" title="Permalink to this definition">¶</a></dt>
<dd><p>Default Authentication tuple or object to attach to
<a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Session.cert"><a name="//apple_ref/cpp/Attribute/requests.Session.cert"></a>
<tt class="descname">cert</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Session.cert" title="Permalink to this definition">¶</a></dt>
<dd><p>SSL certificate default.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Session.close"><a name="//apple_ref/cpp/Method/requests.Session.close"></a>
<tt class="descname">close</tt><big>(</big><big>)</big><a class="headerlink" href="#requests.Session.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Closes all adapters and as such the session</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Session.cookies"><a name="//apple_ref/cpp/Attribute/requests.Session.cookies"></a>
<tt class="descname">cookies</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Session.cookies" title="Permalink to this definition">¶</a></dt>
<dd><p>A CookieJar containing all currently outstanding cookies set on this
session. By default it is a
<tt class="xref py py-class docutils literal"><span class="pre">RequestsCookieJar</span></tt>, but
may be any other <tt class="docutils literal"><span class="pre">cookielib.CookieJar</span></tt> compatible object.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Session.delete"><a name="//apple_ref/cpp/Method/requests.Session.delete"></a>
<tt class="descname">delete</tt><big>(</big><em>url</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.Session.delete" title="Permalink to this definition">¶</a></dt>
<dd><p>Sends a DELETE request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests.Session.get"><a name="//apple_ref/cpp/Method/requests.Session.get"></a>
<tt class="descname">get</tt><big>(</big><em>url</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.Session.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Sends a GET request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests.Session.get_adapter"><a name="//apple_ref/cpp/Method/requests.Session.get_adapter"></a>
<tt class="descname">get_adapter</tt><big>(</big><em>url</em><big>)</big><a class="headerlink" href="#requests.Session.get_adapter" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the appropriate connnection adapter for the given URL.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Session.head"><a name="//apple_ref/cpp/Method/requests.Session.head"></a>
<tt class="descname">head</tt><big>(</big><em>url</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.Session.head" title="Permalink to this definition">¶</a></dt>
<dd><p>Sends a HEAD request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="requests.Session.headers"><a name="//apple_ref/cpp/Attribute/requests.Session.headers"></a>
<tt class="descname">headers</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Session.headers" title="Permalink to this definition">¶</a></dt>
<dd><p>A case-insensitive dictionary of headers to be sent on each
<a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> sent from this
<a class="reference internal" href="#requests.Session" title="requests.Session"><tt class="xref py py-class docutils literal"><span class="pre">Session</span></tt></a>.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Session.hooks"><a name="//apple_ref/cpp/Attribute/requests.Session.hooks"></a>
<tt class="descname">hooks</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Session.hooks" title="Permalink to this definition">¶</a></dt>
<dd><p>Event-handling hooks.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Session.max_redirects"><a name="//apple_ref/cpp/Attribute/requests.Session.max_redirects"></a>
<tt class="descname">max_redirects</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Session.max_redirects" title="Permalink to this definition">¶</a></dt>
<dd><p>Maximum number of redirects allowed. If the request exceeds this
limit, a <tt class="xref py py-class docutils literal"><span class="pre">TooManyRedirects</span></tt> exception is raised.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Session.mount"><a name="//apple_ref/cpp/Method/requests.Session.mount"></a>
<tt class="descname">mount</tt><big>(</big><em>prefix</em>, <em>adapter</em><big>)</big><a class="headerlink" href="#requests.Session.mount" title="Permalink to this definition">¶</a></dt>
<dd><p>Registers a connection adapter to a prefix.</p>
<p>Adapters are sorted in descending order by key length.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Session.options"><a name="//apple_ref/cpp/Method/requests.Session.options"></a>
<tt class="descname">options</tt><big>(</big><em>url</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.Session.options" title="Permalink to this definition">¶</a></dt>
<dd><p>Sends a OPTIONS request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="requests.Session.params"><a name="//apple_ref/cpp/Attribute/requests.Session.params"></a>
<tt class="descname">params</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Session.params" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary of querystring data to attach to each
<a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>. The dictionary values may be lists for
representing multivalued query parameters.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Session.patch"><a name="//apple_ref/cpp/Method/requests.Session.patch"></a>
<tt class="descname">patch</tt><big>(</big><em>url</em>, <em>data=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.Session.patch" title="Permalink to this definition">¶</a></dt>
<dd><p>Sends a PATCH request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>data</strong> – (optional) Dictionary, bytes, or file-like object to send in the body of the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests.Session.post"><a name="//apple_ref/cpp/Method/requests.Session.post"></a>
<tt class="descname">post</tt><big>(</big><em>url</em>, <em>data=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.Session.post" title="Permalink to this definition">¶</a></dt>
<dd><p>Sends a POST request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>data</strong> – (optional) Dictionary, bytes, or file-like object to send in the body of the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests.Session.prepare_request"><a name="//apple_ref/cpp/Method/requests.Session.prepare_request"></a>
<tt class="descname">prepare_request</tt><big>(</big><em>request</em><big>)</big><a class="headerlink" href="#requests.Session.prepare_request" title="Permalink to this definition">¶</a></dt>
<dd><p>Constructs a <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> for
transmission and returns it. The <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> has settings
merged from the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> instance and those of the
<a class="reference internal" href="#requests.Session" title="requests.Session"><tt class="xref py py-class docutils literal"><span class="pre">Session</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>request</strong> – <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> instance to prepare with this
session’s settings.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="requests.Session.proxies"><a name="//apple_ref/cpp/Attribute/requests.Session.proxies"></a>
<tt class="descname">proxies</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Session.proxies" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary mapping protocol to the URL of the proxy (e.g.
{‘http’: ‘foo.bar:3128’}) to be used on each
<a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Session.put"><a name="//apple_ref/cpp/Method/requests.Session.put"></a>
<tt class="descname">put</tt><big>(</big><em>url</em>, <em>data=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.Session.put" title="Permalink to this definition">¶</a></dt>
<dd><p>Sends a PUT request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>data</strong> – (optional) Dictionary, bytes, or file-like object to send in the body of the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests.Session.rebuild_auth"><a name="//apple_ref/cpp/Method/requests.Session.rebuild_auth"></a>
<tt class="descname">rebuild_auth</tt><big>(</big><em>prepared_request</em>, <em>response</em><big>)</big><a class="headerlink" href="#requests.Session.rebuild_auth" title="Permalink to this definition">¶</a></dt>
<dd><p>When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Session.rebuild_proxies"><a name="//apple_ref/cpp/Method/requests.Session.rebuild_proxies"></a>
<tt class="descname">rebuild_proxies</tt><big>(</big><em>prepared_request</em>, <em>proxies</em><big>)</big><a class="headerlink" href="#requests.Session.rebuild_proxies" title="Permalink to this definition">¶</a></dt>
<dd><p>This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in case they were stripped by a previous
redirect).</p>
<p>This method also replaces the Proxy-Authorization header where
necessary.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Session.request"><a name="//apple_ref/cpp/Method/requests.Session.request"></a>
<tt class="descname">request</tt><big>(</big><em>method</em>, <em>url</em>, <em>params=None</em>, <em>data=None</em>, <em>headers=None</em>, <em>cookies=None</em>, <em>files=None</em>, <em>auth=None</em>, <em>timeout=None</em>, <em>allow_redirects=True</em>, <em>proxies=None</em>, <em>hooks=None</em>, <em>stream=None</em>, <em>verify=None</em>, <em>cert=None</em><big>)</big><a class="headerlink" href="#requests.Session.request" title="Permalink to this definition">¶</a></dt>
<dd><p>Constructs a <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>, prepares it and sends it.
Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>method</strong> – method for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>params</strong> – (optional) Dictionary or bytes to be sent in the query
string for the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>data</strong> – (optional) Dictionary or bytes to send in the body of the
<a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>headers</strong> – (optional) Dictionary of HTTP Headers to send with the
<a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>cookies</strong> – (optional) Dict or CookieJar object to send with the
<a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>files</strong> – (optional) Dictionary of ‘filename’: file-like-objects
for multipart encoding upload.</li>
<li><strong>auth</strong> – (optional) Auth tuple or callable to enable
Basic/Digest/Custom HTTP Auth.</li>
<li><strong>timeout</strong> – (optional) Float describing the timeout of the
request in seconds.</li>
<li><strong>allow_redirects</strong> – (optional) Boolean. Set to True by default.</li>
<li><strong>proxies</strong> – (optional) Dictionary mapping protocol to the URL of
the proxy.</li>
<li><strong>stream</strong> – (optional) whether to immediately download the response
content. Defaults to <tt class="docutils literal"><span class="pre">False</span></tt>.</li>
<li><strong>verify</strong> – (optional) if <tt class="docutils literal"><span class="pre">True</span></tt>, the SSL cert will be verified.
A CA_BUNDLE path can also be provided.</li>
<li><strong>cert</strong> – (optional) if String, path to ssl client cert file (.pem).
If Tuple, (‘cert’, ‘key’) pair.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests.Session.resolve_redirects"><a name="//apple_ref/cpp/Method/requests.Session.resolve_redirects"></a>
<tt class="descname">resolve_redirects</tt><big>(</big><em>resp</em>, <em>req</em>, <em>stream=False</em>, <em>timeout=None</em>, <em>verify=True</em>, <em>cert=None</em>, <em>proxies=None</em><big>)</big><a class="headerlink" href="#requests.Session.resolve_redirects" title="Permalink to this definition">¶</a></dt>
<dd><p>Receives a Response. Returns a generator of Responses.</p>
</dd></dl>
<dl class="method">
<dt id="requests.Session.send"><a name="//apple_ref/cpp/Method/requests.Session.send"></a>
<tt class="descname">send</tt><big>(</big><em>request</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.Session.send" title="Permalink to this definition">¶</a></dt>
<dd><p>Send a given PreparedRequest.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Session.stream"><a name="//apple_ref/cpp/Attribute/requests.Session.stream"></a>
<tt class="descname">stream</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Session.stream" title="Permalink to this definition">¶</a></dt>
<dd><p>Stream response content default.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Session.trust_env"><a name="//apple_ref/cpp/Attribute/requests.Session.trust_env"></a>
<tt class="descname">trust_env</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Session.trust_env" title="Permalink to this definition">¶</a></dt>
<dd><p>Should we trust the environment?</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.Session.verify"><a name="//apple_ref/cpp/Attribute/requests.Session.verify"></a>
<tt class="descname">verify</tt><em class="property"> = None</em><a class="headerlink" href="#requests.Session.verify" title="Permalink to this definition">¶</a></dt>
<dd><p>SSL Verification default.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="requests.adapters.HTTPAdapter"><a name="//apple_ref/cpp/Class/requests.adapters.HTTPAdapter"></a>
<em class="property">class </em><tt class="descclassname">requests.adapters.</tt><tt class="descname">HTTPAdapter</tt><big>(</big><em>pool_connections=10</em>, <em>pool_maxsize=10</em>, <em>max_retries=0</em>, <em>pool_block=False</em><big>)</big><a class="headerlink" href="#requests.adapters.HTTPAdapter" title="Permalink to this definition">¶</a></dt>
<dd><p>The built-in HTTP Adapter for urllib3.</p>
<p>Provides a general-case interface for Requests sessions to contact HTTP and
HTTPS urls by implementing the Transport Adapter interface. This class will
usually be created by the <a class="reference internal" href="#requests.Session" title="requests.Session"><tt class="xref py py-class docutils literal"><span class="pre">Session</span></tt></a> class under the
covers.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>pool_connections</strong> – The number of urllib3 connection pools to cache.</li>
<li><strong>pool_maxsize</strong> – The maximum number of connections to save in the pool.</li>
<li><strong>max_retries</strong> (<em>int</em>) – The maximum number of retries each connection
should attempt. Note, this applies only to failed connections and
timeouts, never to requests where the server returns a response.</li>
<li><strong>pool_block</strong> – Whether the connection pool should block for connections.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Usage:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">requests</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">Session</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">adapters</span><span class="o">.</span><span class="n">HTTPAdapter</span><span class="p">(</span><span class="n">max_retries</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">mount</span><span class="p">(</span><span class="s">'http://'</span><span class="p">,</span> <span class="n">a</span><span class="p">)</span>
</pre></div>
</div>
<dl class="method">
<dt id="requests.adapters.HTTPAdapter.add_headers"><a name="//apple_ref/cpp/Method/requests.adapters.HTTPAdapter.add_headers"></a>
<tt class="descname">add_headers</tt><big>(</big><em>request</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.adapters.HTTPAdapter.add_headers" title="Permalink to this definition">¶</a></dt>
<dd><p>Add any headers needed by the connection. As of v2.0 this does
nothing by default, but is left for overriding by users that subclass
the <a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a>.</p>
<p>This should not be called from user code, and is only exposed for use
when subclassing the
<a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>request</strong> – The <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> to add headers to.</li>
<li><strong>kwargs</strong> – The keyword arguments from the call to send().</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests.adapters.HTTPAdapter.build_response"><a name="//apple_ref/cpp/Method/requests.adapters.HTTPAdapter.build_response"></a>
<tt class="descname">build_response</tt><big>(</big><em>req</em>, <em>resp</em><big>)</big><a class="headerlink" href="#requests.adapters.HTTPAdapter.build_response" title="Permalink to this definition">¶</a></dt>
<dd><p>Builds a <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object from a urllib3
response. This should not be called from user code, and is only exposed
for use when subclassing the
<a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>req</strong> – The <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> used to generate the response.</li>
<li><strong>resp</strong> – The urllib3 response object.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests.adapters.HTTPAdapter.cert_verify"><a name="//apple_ref/cpp/Method/requests.adapters.HTTPAdapter.cert_verify"></a>
<tt class="descname">cert_verify</tt><big>(</big><em>conn</em>, <em>url</em>, <em>verify</em>, <em>cert</em><big>)</big><a class="headerlink" href="#requests.adapters.HTTPAdapter.cert_verify" title="Permalink to this definition">¶</a></dt>
<dd><p>Verify a SSL certificate. This method should not be called from user
code, and is only exposed for use when subclassing the
<a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>conn</strong> – The urllib3 connection object associated with the cert.</li>
<li><strong>url</strong> – The requested URL.</li>
<li><strong>verify</strong> – Whether we should actually verify the certificate.</li>
<li><strong>cert</strong> – The SSL certificate to verify.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests.adapters.HTTPAdapter.close"><a name="//apple_ref/cpp/Method/requests.adapters.HTTPAdapter.close"></a>
<tt class="descname">close</tt><big>(</big><big>)</big><a class="headerlink" href="#requests.adapters.HTTPAdapter.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Disposes of any internal state.</p>
<p>Currently, this just closes the PoolManager, which closes pooled
connections.</p>
</dd></dl>
<dl class="method">
<dt id="requests.adapters.HTTPAdapter.get_connection"><a name="//apple_ref/cpp/Method/requests.adapters.HTTPAdapter.get_connection"></a>
<tt class="descname">get_connection</tt><big>(</big><em>url</em>, <em>proxies=None</em><big>)</big><a class="headerlink" href="#requests.adapters.HTTPAdapter.get_connection" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a urllib3 connection for the given URL. This should not be
called from user code, and is only exposed for use when subclassing the
<a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – The URL to connect to.</li>
<li><strong>proxies</strong> – (optional) A Requests-style dictionary of proxies used on this request.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests.adapters.HTTPAdapter.init_poolmanager"><a name="//apple_ref/cpp/Method/requests.adapters.HTTPAdapter.init_poolmanager"></a>
<tt class="descname">init_poolmanager</tt><big>(</big><em>connections</em>, <em>maxsize</em>, <em>block=False</em><big>)</big><a class="headerlink" href="#requests.adapters.HTTPAdapter.init_poolmanager" title="Permalink to this definition">¶</a></dt>
<dd><p>Initializes a urllib3 PoolManager. This method should not be called
from user code, and is only exposed for use when subclassing the
<a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>connections</strong> – The number of urllib3 connection pools to cache.</li>
<li><strong>maxsize</strong> – The maximum number of connections to save in the pool.</li>
<li><strong>block</strong> – Block when no free connections are available.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests.adapters.HTTPAdapter.proxy_headers"><a name="//apple_ref/cpp/Method/requests.adapters.HTTPAdapter.proxy_headers"></a>
<tt class="descname">proxy_headers</tt><big>(</big><em>proxy</em><big>)</big><a class="headerlink" href="#requests.adapters.HTTPAdapter.proxy_headers" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a dictionary of the headers to add to any request sent
through a proxy. This works with urllib3 magic to ensure that they are
correctly sent to the proxy, rather than in a tunnelled request if
CONNECT is being used.</p>
<p>This should not be called from user code, and is only exposed for use
when subclassing the
<a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>proxies</strong> – The url of the proxy being used for this request.</li>
<li><strong>kwargs</strong> – Optional additional keyword arguments.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests.adapters.HTTPAdapter.request_url"><a name="//apple_ref/cpp/Method/requests.adapters.HTTPAdapter.request_url"></a>
<tt class="descname">request_url</tt><big>(</big><em>request</em>, <em>proxies</em><big>)</big><a class="headerlink" href="#requests.adapters.HTTPAdapter.request_url" title="Permalink to this definition">¶</a></dt>
<dd><p>Obtain the url to use when making the final request.</p>
<p>If the message is being sent through a HTTP proxy, the full URL has to
be used. Otherwise, we should only use the path portion of the URL.</p>
<p>This should not be called from user code, and is only exposed for use
when subclassing the
<a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>request</strong> – The <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> being sent.</li>
<li><strong>proxies</strong> – A dictionary of schemes to proxy URLs.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests.adapters.HTTPAdapter.send"><a name="//apple_ref/cpp/Method/requests.adapters.HTTPAdapter.send"></a>
<tt class="descname">send</tt><big>(</big><em>request</em>, <em>stream=False</em>, <em>timeout=None</em>, <em>verify=True</em>, <em>cert=None</em>, <em>proxies=None</em><big>)</big><a class="headerlink" href="#requests.adapters.HTTPAdapter.send" title="Permalink to this definition">¶</a></dt>
<dd><p>Sends PreparedRequest object. Returns Response object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>request</strong> – The <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> being sent.</li>
<li><strong>stream</strong> – (optional) Whether to stream the request content.</li>
<li><strong>timeout</strong> – (optional) The timeout on the request.</li>
<li><strong>verify</strong> – (optional) Whether to verify SSL certificates.</li>
<li><strong>cert</strong> – (optional) Any user-provided SSL certificate to be trusted.</li>
<li><strong>proxies</strong> – (optional) The proxies dictionary to apply to the request.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="authentication">
<h2>Authentication<a class="headerlink" href="#authentication" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="requests.auth.AuthBase"><a name="//apple_ref/cpp/Class/requests.auth.AuthBase"></a>
<em class="property">class </em><tt class="descclassname">requests.auth.</tt><tt class="descname">AuthBase</tt><a class="headerlink" href="#requests.auth.AuthBase" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class that all auth implementations derive from</p>
</dd></dl>
<dl class="class">
<dt id="requests.auth.HTTPBasicAuth"><a name="//apple_ref/cpp/Class/requests.auth.HTTPBasicAuth"></a>
<em class="property">class </em><tt class="descclassname">requests.auth.</tt><tt class="descname">HTTPBasicAuth</tt><big>(</big><em>username</em>, <em>password</em><big>)</big><a class="headerlink" href="#requests.auth.HTTPBasicAuth" title="Permalink to this definition">¶</a></dt>
<dd><p>Attaches HTTP Basic Authentication to the given Request object.</p>
</dd></dl>
<dl class="class">
<dt id="requests.auth.HTTPProxyAuth"><a name="//apple_ref/cpp/Class/requests.auth.HTTPProxyAuth"></a>
<em class="property">class </em><tt class="descclassname">requests.auth.</tt><tt class="descname">HTTPProxyAuth</tt><big>(</big><em>username</em>, <em>password</em><big>)</big><a class="headerlink" href="#requests.auth.HTTPProxyAuth" title="Permalink to this definition">¶</a></dt>
<dd><p>Attaches HTTP Proxy Authentication to a given Request object.</p>
</dd></dl>
<dl class="class">
<dt id="requests.auth.HTTPDigestAuth"><a name="//apple_ref/cpp/Class/requests.auth.HTTPDigestAuth"></a>
<em class="property">class </em><tt class="descclassname">requests.auth.</tt><tt class="descname">HTTPDigestAuth</tt><big>(</big><em>username</em>, <em>password</em><big>)</big><a class="headerlink" href="#requests.auth.HTTPDigestAuth" title="Permalink to this definition">¶</a></dt>
<dd><p>Attaches HTTP Digest Authentication to the given Request object.</p>
</dd></dl>
<div class="section" id="exceptions">
<h3>Exceptions<a class="headerlink" href="#exceptions" title="Permalink to this headline">¶</a></h3>
<dl class="exception">
<dt id="requests.exceptions.RequestException"><a name="//apple_ref/cpp/Exception/requests.exceptions.RequestException"></a>
<em class="property">exception </em><tt class="descclassname">requests.exceptions.</tt><tt class="descname">RequestException</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.exceptions.RequestException" title="Permalink to this definition">¶</a></dt>
<dd><p>There was an ambiguous exception that occurred while handling your
request.</p>
</dd></dl>
<dl class="exception">
<dt id="requests.exceptions.ConnectionError"><a name="//apple_ref/cpp/Exception/requests.exceptions.ConnectionError"></a>
<em class="property">exception </em><tt class="descclassname">requests.exceptions.</tt><tt class="descname">ConnectionError</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.exceptions.ConnectionError" title="Permalink to this definition">¶</a></dt>
<dd><p>A Connection error occurred.</p>
</dd></dl>
<dl class="exception">
<dt id="requests.exceptions.HTTPError"><a name="//apple_ref/cpp/Exception/requests.exceptions.HTTPError"></a>
<em class="property">exception </em><tt class="descclassname">requests.exceptions.</tt><tt class="descname">HTTPError</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.exceptions.HTTPError" title="Permalink to this definition">¶</a></dt>
<dd><p>An HTTP error occurred.</p>
</dd></dl>
<dl class="exception">
<dt id="requests.exceptions.URLRequired"><a name="//apple_ref/cpp/Exception/requests.exceptions.URLRequired"></a>
<em class="property">exception </em><tt class="descclassname">requests.exceptions.</tt><tt class="descname">URLRequired</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.exceptions.URLRequired" title="Permalink to this definition">¶</a></dt>
<dd><p>A valid URL is required to make a request.</p>
</dd></dl>
<dl class="exception">
<dt id="requests.exceptions.TooManyRedirects"><a name="//apple_ref/cpp/Exception/requests.exceptions.TooManyRedirects"></a>
<em class="property">exception </em><tt class="descclassname">requests.exceptions.</tt><tt class="descname">TooManyRedirects</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.exceptions.TooManyRedirects" title="Permalink to this definition">¶</a></dt>
<dd><p>Too many redirects.</p>
</dd></dl>
<dl class="exception">
<dt id="requests.exceptions.Timeout"><a name="//apple_ref/cpp/Exception/requests.exceptions.Timeout"></a>
<em class="property">exception </em><tt class="descclassname">requests.exceptions.</tt><tt class="descname">Timeout</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#requests.exceptions.Timeout" title="Permalink to this definition">¶</a></dt>
<dd><p>The request timed out.</p>
</dd></dl>
</div>
<div class="section" id="status-code-lookup">
<h3>Status Code Lookup<a class="headerlink" href="#status-code-lookup" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="requests.codes"><a name="//apple_ref/cpp/Function/requests.codes"></a>
<tt class="descclassname">requests.</tt><tt class="descname">codes</tt><big>(</big><big>)</big><a class="headerlink" href="#requests.codes" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary lookup object.</p>
</dd></dl>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">requests</span><span class="o">.</span><span class="n">codes</span><span class="p">[</span><span class="s">'temporary_redirect'</span><span class="p">]</span>
<span class="go">307</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">requests</span><span class="o">.</span><span class="n">codes</span><span class="o">.</span><span class="n">teapot</span>
<span class="go">418</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">requests</span><span class="o">.</span><span class="n">codes</span><span class="p">[</span><span class="s">'\o/'</span><span class="p">]</span>
<span class="go">200</span>
</pre></div>
</div>
</div>
<div class="section" id="cookies">
<h3>Cookies<a class="headerlink" href="#cookies" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="requests.utils.dict_from_cookiejar"><a name="//apple_ref/cpp/Function/requests.utils.dict_from_cookiejar"></a>
<tt class="descclassname">requests.utils.</tt><tt class="descname">dict_from_cookiejar</tt><big>(</big><em>cj</em><big>)</big><a class="headerlink" href="#requests.utils.dict_from_cookiejar" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a key/value dictionary from a CookieJar.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>cj</strong> – CookieJar object to extract cookies from.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="requests.utils.cookiejar_from_dict"><a name="//apple_ref/cpp/Function/requests.utils.cookiejar_from_dict"></a>
<tt class="descclassname">requests.utils.</tt><tt class="descname">cookiejar_from_dict</tt><big>(</big><em>cookie_dict</em>, <em>cookiejar=None</em>, <em>overwrite=True</em><big>)</big><a class="headerlink" href="#requests.utils.cookiejar_from_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a CookieJar from a key/value dictionary.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>cookie_dict</strong> – Dict of key/values to insert into CookieJar.</li>
<li><strong>cookiejar</strong> – (optional) A cookiejar to add the cookies to.</li>
<li><strong>overwrite</strong> – (optional) If False, will not replace cookies
already in the jar with new ones.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="requests.utils.add_dict_to_cookiejar"><a name="//apple_ref/cpp/Function/requests.utils.add_dict_to_cookiejar"></a>
<tt class="descclassname">requests.utils.</tt><tt class="descname">add_dict_to_cookiejar</tt><big>(</big><em>cj</em>, <em>cookie_dict</em><big>)</big><a class="headerlink" href="#requests.utils.add_dict_to_cookiejar" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a CookieJar from a key/value dictionary.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>cj</strong> – CookieJar to insert cookies into.</li>
<li><strong>cookie_dict</strong> – Dict of key/values to insert into CookieJar.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="encodings">
<h3>Encodings<a class="headerlink" href="#encodings" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="requests.utils.get_encodings_from_content"><a name="//apple_ref/cpp/Function/requests.utils.get_encodings_from_content"></a>
<tt class="descclassname">requests.utils.</tt><tt class="descname">get_encodings_from_content</tt><big>(</big><em>content</em><big>)</big><a class="headerlink" href="#requests.utils.get_encodings_from_content" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns encodings from given content string.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>content</strong> – bytestring to extract encodings from.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="requests.utils.get_encoding_from_headers"><a name="//apple_ref/cpp/Function/requests.utils.get_encoding_from_headers"></a>
<tt class="descclassname">requests.utils.</tt><tt class="descname">get_encoding_from_headers</tt><big>(</big><em>headers</em><big>)</big><a class="headerlink" href="#requests.utils.get_encoding_from_headers" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns encodings from given HTTP Header Dict.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>headers</strong> – dictionary to extract encoding from.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="requests.utils.get_unicode_from_response"><a name="//apple_ref/cpp/Function/requests.utils.get_unicode_from_response"></a>
<tt class="descclassname">requests.utils.</tt><tt class="descname">get_unicode_from_response</tt><big>(</big><em>r</em><big>)</big><a class="headerlink" href="#requests.utils.get_unicode_from_response" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the requested content back in unicode.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>r</strong> – Response object to get unicode content from.</td>
</tr>
</tbody>
</table>
<p>Tried:</p>
<ol class="arabic simple">
<li>charset from content-type</li>
<li>every encodings from <tt class="docutils literal"><span class="pre">&lt;meta</span> <span class="pre">...</span> <span class="pre">charset=XXX&gt;</span></tt></li>
<li>fall back and replace all unicode characters</li>
</ol>
</dd></dl>
</div>
<div class="section" id="classes">
<h3>Classes<a class="headerlink" href="#classes" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt>
<em class="property">class </em><tt class="descclassname">requests.</tt><tt class="descname">Response</tt></dt>
<dd><p>The <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object, which contains a
server’s response to an HTTP request.</p>
<dl class="attribute">
<dt>
<tt class="descname">apparent_encoding</tt></dt>
<dd><p>The apparent encoding, provided by the chardet library</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">close</tt><big>(</big><big>)</big></dt>
<dd><p>Releases the connection back to the pool. Once this method has been
called the underlying <tt class="docutils literal"><span class="pre">raw</span></tt> object must not be accessed again.</p>
<p><em>Note: Should not normally need to be called explicitly.</em></p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">content</tt></dt>
<dd><p>Content of the response, in bytes.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">cookies</tt><em class="property"> = None</em></dt>
<dd><p>A CookieJar of Cookies the server sent back.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">elapsed</tt><em class="property"> = None</em></dt>
<dd><p>The amount of time elapsed between sending the request
and the arrival of the response (as a timedelta)</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">encoding</tt><em class="property"> = None</em></dt>
<dd><p>Encoding to decode with when accessing r.text.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">headers</tt><em class="property"> = None</em></dt>
<dd><p>Case-insensitive Dictionary of Response Headers.
For example, <tt class="docutils literal"><span class="pre">headers['content-encoding']</span></tt> will return the
value of a <tt class="docutils literal"><span class="pre">'Content-Encoding'</span></tt> response header.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">history</tt><em class="property"> = None</em></dt>
<dd><p>A list of <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> objects from
the history of the Request. Any redirect responses will end
up here. The list is sorted from the oldest to the most recent request.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">is_redirect</tt></dt>
<dd><p>True if this Response is a well-formed HTTP redirect that could have
been processed automatically (by <a class="reference internal" href="#requests.Session.resolve_redirects" title="requests.Session.resolve_redirects"><tt class="xref py py-meth docutils literal"><span class="pre">Session.resolve_redirects()</span></tt></a>).</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">iter_content</tt><big>(</big><em>chunk_size=1</em>, <em>decode_unicode=False</em><big>)</big></dt>
<dd><p>Iterates over the response data.  When stream=True is set on the
request, this avoids reading the content at once into memory for
large responses.  The chunk size is the number of bytes it should
read into memory.  This is not necessarily the length of each item
returned as decoding can take place.</p>
<p>If decode_unicode is True, content will be decoded using the best
available encoding based on the response.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">iter_lines</tt><big>(</big><em>chunk_size=512</em>, <em>decode_unicode=None</em><big>)</big></dt>
<dd><p>Iterates over the response data, one line at a time.  When
stream=True is set on the request, this avoids reading the
content at once into memory for large responses.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">json</tt><big>(</big><em>**kwargs</em><big>)</big></dt>
<dd><p>Returns the json-encoded content of a response, if any.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">json.loads</span></tt> takes.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">links</tt></dt>
<dd><p>Returns the parsed header links of the response, if any.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">raise_for_status</tt><big>(</big><big>)</big></dt>
<dd><p>Raises stored <tt class="xref py py-class docutils literal"><span class="pre">HTTPError</span></tt>, if one occurred.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">raw</tt><em class="property"> = None</em></dt>
<dd><p>File-like object representation of response (for advanced usage).
Use of <tt class="docutils literal"><span class="pre">raw</span></tt> requires that <tt class="docutils literal"><span class="pre">stream=True</span></tt> be set on the request.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">reason</tt><em class="property"> = None</em></dt>
<dd><p>Textual reason of responded HTTP Status, e.g. “Not Found” or “OK”.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">status_code</tt><em class="property"> = None</em></dt>
<dd><p>Integer Code of responded HTTP Status, e.g. 404 or 200.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">text</tt></dt>
<dd><p>Content of the response, in unicode.</p>
<p>If Response.encoding is None, encoding will be guessed using
<tt class="docutils literal"><span class="pre">chardet</span></tt>.</p>
<p>The encoding of the response content is determined based solely on HTTP
headers, following RFC 2616 to the letter. If you can take advantage of
non-HTTP knowledge to make a better guess at the encoding, you should
set <tt class="docutils literal"><span class="pre">r.encoding</span></tt> appropriately before accessing this property.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">url</tt><em class="property"> = None</em></dt>
<dd><p>Final URL location of Response.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt>
<em class="property">class </em><tt class="descclassname">requests.</tt><tt class="descname">Request</tt><big>(</big><em>method=None</em>, <em>url=None</em>, <em>headers=None</em>, <em>files=None</em>, <em>data=None</em>, <em>params=None</em>, <em>auth=None</em>, <em>cookies=None</em>, <em>hooks=None</em><big>)</big></dt>
<dd><p>A user-created <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</p>
<p>Used to prepare a <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a>, which is sent to the server.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>method</strong> – HTTP method to use.</li>
<li><strong>url</strong> – URL to send.</li>
<li><strong>headers</strong> – dictionary of headers to send.</li>
<li><strong>files</strong> – dictionary of {filename: fileobject} files to multipart upload.</li>
<li><strong>data</strong> – the body to attach the request. If a dictionary is provided, form-encoding will take place.</li>
<li><strong>params</strong> – dictionary of URL parameters to append to the URL.</li>
<li><strong>auth</strong> – Auth handler or (user, pass) tuple.</li>
<li><strong>cookies</strong> – dictionary or CookieJar of cookies to attach to this request.</li>
<li><strong>hooks</strong> – dictionary of callback hooks, for internal usage.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Usage:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">requests</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">req</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">Request</span><span class="p">(</span><span class="s">'GET'</span><span class="p">,</span> <span class="s">'http://httpbin.org/get'</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">req</span><span class="o">.</span><span class="n">prepare</span><span class="p">()</span>
<span class="go">&lt;PreparedRequest [GET]&gt;</span>
</pre></div>
</div>
<dl class="method">
<dt>
<tt class="descname">deregister_hook</tt><big>(</big><em>event</em>, <em>hook</em><big>)</big></dt>
<dd><p>Deregister a previously registered hook.
Returns True if the hook existed, False if not.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">prepare</tt><big>(</big><big>)</big></dt>
<dd><p>Constructs a <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> for transmission and returns it.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">register_hook</tt><big>(</big><em>event</em>, <em>hook</em><big>)</big></dt>
<dd><p>Properly register a hook.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="requests.PreparedRequest"><a name="//apple_ref/cpp/Class/requests.PreparedRequest"></a>
<em class="property">class </em><tt class="descclassname">requests.</tt><tt class="descname">PreparedRequest</tt><a class="headerlink" href="#requests.PreparedRequest" title="Permalink to this definition">¶</a></dt>
<dd><p>The fully mutable <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> object,
containing the exact bytes that will be sent to the server.</p>
<p>Generated from either a <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object or manually.</p>
<p>Usage:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">requests</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">req</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">Request</span><span class="p">(</span><span class="s">'GET'</span><span class="p">,</span> <span class="s">'http://httpbin.org/get'</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">r</span> <span class="o">=</span> <span class="n">req</span><span class="o">.</span><span class="n">prepare</span><span class="p">()</span>
<span class="go">&lt;PreparedRequest [GET]&gt;</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">Session</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">r</span><span class="p">)</span>
<span class="go">&lt;Response [200]&gt;</span>
</pre></div>
</div>
<dl class="attribute">
<dt id="requests.PreparedRequest.body"><a name="//apple_ref/cpp/Attribute/requests.PreparedRequest.body"></a>
<tt class="descname">body</tt><em class="property"> = None</em><a class="headerlink" href="#requests.PreparedRequest.body" title="Permalink to this definition">¶</a></dt>
<dd><p>request body to send to the server.</p>
</dd></dl>
<dl class="method">
<dt id="requests.PreparedRequest.deregister_hook"><a name="//apple_ref/cpp/Method/requests.PreparedRequest.deregister_hook"></a>
<tt class="descname">deregister_hook</tt><big>(</big><em>event</em>, <em>hook</em><big>)</big><a class="headerlink" href="#requests.PreparedRequest.deregister_hook" title="Permalink to this definition">¶</a></dt>
<dd><p>Deregister a previously registered hook.
Returns True if the hook existed, False if not.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.PreparedRequest.headers"><a name="//apple_ref/cpp/Attribute/requests.PreparedRequest.headers"></a>
<tt class="descname">headers</tt><em class="property"> = None</em><a class="headerlink" href="#requests.PreparedRequest.headers" title="Permalink to this definition">¶</a></dt>
<dd><p>dictionary of HTTP headers.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.PreparedRequest.hooks"><a name="//apple_ref/cpp/Attribute/requests.PreparedRequest.hooks"></a>
<tt class="descname">hooks</tt><em class="property"> = None</em><a class="headerlink" href="#requests.PreparedRequest.hooks" title="Permalink to this definition">¶</a></dt>
<dd><p>dictionary of callback hooks, for internal usage.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.PreparedRequest.method"><a name="//apple_ref/cpp/Attribute/requests.PreparedRequest.method"></a>
<tt class="descname">method</tt><em class="property"> = None</em><a class="headerlink" href="#requests.PreparedRequest.method" title="Permalink to this definition">¶</a></dt>
<dd><p>HTTP verb to send to the server.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.PreparedRequest.path_url"><a name="//apple_ref/cpp/Attribute/requests.PreparedRequest.path_url"></a>
<tt class="descname">path_url</tt><a class="headerlink" href="#requests.PreparedRequest.path_url" title="Permalink to this definition">¶</a></dt>
<dd><p>Build the path URL to use.</p>
</dd></dl>
<dl class="method">
<dt id="requests.PreparedRequest.prepare"><a name="//apple_ref/cpp/Method/requests.PreparedRequest.prepare"></a>
<tt class="descname">prepare</tt><big>(</big><em>method=None</em>, <em>url=None</em>, <em>headers=None</em>, <em>files=None</em>, <em>data=None</em>, <em>params=None</em>, <em>auth=None</em>, <em>cookies=None</em>, <em>hooks=None</em><big>)</big><a class="headerlink" href="#requests.PreparedRequest.prepare" title="Permalink to this definition">¶</a></dt>
<dd><p>Prepares the entire request with the given parameters.</p>
</dd></dl>
<dl class="method">
<dt id="requests.PreparedRequest.prepare_auth"><a name="//apple_ref/cpp/Method/requests.PreparedRequest.prepare_auth"></a>
<tt class="descname">prepare_auth</tt><big>(</big><em>auth</em>, <em>url=''</em><big>)</big><a class="headerlink" href="#requests.PreparedRequest.prepare_auth" title="Permalink to this definition">¶</a></dt>
<dd><p>Prepares the given HTTP auth data.</p>
</dd></dl>
<dl class="method">
<dt id="requests.PreparedRequest.prepare_body"><a name="//apple_ref/cpp/Method/requests.PreparedRequest.prepare_body"></a>
<tt class="descname">prepare_body</tt><big>(</big><em>data</em>, <em>files</em><big>)</big><a class="headerlink" href="#requests.PreparedRequest.prepare_body" title="Permalink to this definition">¶</a></dt>
<dd><p>Prepares the given HTTP body data.</p>
</dd></dl>
<dl class="method">
<dt id="requests.PreparedRequest.prepare_cookies"><a name="//apple_ref/cpp/Method/requests.PreparedRequest.prepare_cookies"></a>
<tt class="descname">prepare_cookies</tt><big>(</big><em>cookies</em><big>)</big><a class="headerlink" href="#requests.PreparedRequest.prepare_cookies" title="Permalink to this definition">¶</a></dt>
<dd><p>Prepares the given HTTP cookie data.</p>
</dd></dl>
<dl class="method">
<dt id="requests.PreparedRequest.prepare_headers"><a name="//apple_ref/cpp/Method/requests.PreparedRequest.prepare_headers"></a>
<tt class="descname">prepare_headers</tt><big>(</big><em>headers</em><big>)</big><a class="headerlink" href="#requests.PreparedRequest.prepare_headers" title="Permalink to this definition">¶</a></dt>
<dd><p>Prepares the given HTTP headers.</p>
</dd></dl>
<dl class="method">
<dt id="requests.PreparedRequest.prepare_hooks"><a name="//apple_ref/cpp/Method/requests.PreparedRequest.prepare_hooks"></a>
<tt class="descname">prepare_hooks</tt><big>(</big><em>hooks</em><big>)</big><a class="headerlink" href="#requests.PreparedRequest.prepare_hooks" title="Permalink to this definition">¶</a></dt>
<dd><p>Prepares the given hooks.</p>
</dd></dl>
<dl class="method">
<dt id="requests.PreparedRequest.prepare_method"><a name="//apple_ref/cpp/Method/requests.PreparedRequest.prepare_method"></a>
<tt class="descname">prepare_method</tt><big>(</big><em>method</em><big>)</big><a class="headerlink" href="#requests.PreparedRequest.prepare_method" title="Permalink to this definition">¶</a></dt>
<dd><p>Prepares the given HTTP method.</p>
</dd></dl>
<dl class="method">
<dt id="requests.PreparedRequest.prepare_url"><a name="//apple_ref/cpp/Method/requests.PreparedRequest.prepare_url"></a>
<tt class="descname">prepare_url</tt><big>(</big><em>url</em>, <em>params</em><big>)</big><a class="headerlink" href="#requests.PreparedRequest.prepare_url" title="Permalink to this definition">¶</a></dt>
<dd><p>Prepares the given HTTP URL.</p>
</dd></dl>
<dl class="method">
<dt id="requests.PreparedRequest.register_hook"><a name="//apple_ref/cpp/Method/requests.PreparedRequest.register_hook"></a>
<tt class="descname">register_hook</tt><big>(</big><em>event</em>, <em>hook</em><big>)</big><a class="headerlink" href="#requests.PreparedRequest.register_hook" title="Permalink to this definition">¶</a></dt>
<dd><p>Properly register a hook.</p>
</dd></dl>
<dl class="attribute">
<dt id="requests.PreparedRequest.url"><a name="//apple_ref/cpp/Attribute/requests.PreparedRequest.url"></a>
<tt class="descname">url</tt><em class="property"> = None</em><a class="headerlink" href="#requests.PreparedRequest.url" title="Permalink to this definition">¶</a></dt>
<dd><p>HTTP URL to send the request to.</p>
</dd></dl>
</dd></dl>
<span class="target" id="sessionapi"></span><dl class="class">
<dt>
<em class="property">class </em><tt class="descclassname">requests.</tt><tt class="descname">Session</tt></dt>
<dd><p>A Requests session.</p>
<p>Provides cookie persistence, connection-pooling, and configuration.</p>
<p>Basic Usage:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">requests</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">Session</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'http://httpbin.org/get'</span><span class="p">)</span>
<span class="go">200</span>
</pre></div>
</div>
<dl class="attribute">
<dt>
<tt class="descname">auth</tt><em class="property"> = None</em></dt>
<dd><p>Default Authentication tuple or object to attach to
<a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">cert</tt><em class="property"> = None</em></dt>
<dd><p>SSL certificate default.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">close</tt><big>(</big><big>)</big></dt>
<dd><p>Closes all adapters and as such the session</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">cookies</tt><em class="property"> = None</em></dt>
<dd><p>A CookieJar containing all currently outstanding cookies set on this
session. By default it is a
<tt class="xref py py-class docutils literal"><span class="pre">RequestsCookieJar</span></tt>, but
may be any other <tt class="docutils literal"><span class="pre">cookielib.CookieJar</span></tt> compatible object.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">delete</tt><big>(</big><em>url</em>, <em>**kwargs</em><big>)</big></dt>
<dd><p>Sends a DELETE request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">get</tt><big>(</big><em>url</em>, <em>**kwargs</em><big>)</big></dt>
<dd><p>Sends a GET request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">get_adapter</tt><big>(</big><em>url</em><big>)</big></dt>
<dd><p>Returns the appropriate connnection adapter for the given URL.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">head</tt><big>(</big><em>url</em>, <em>**kwargs</em><big>)</big></dt>
<dd><p>Sends a HEAD request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">headers</tt><em class="property"> = None</em></dt>
<dd><p>A case-insensitive dictionary of headers to be sent on each
<a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> sent from this
<a class="reference internal" href="#requests.Session" title="requests.Session"><tt class="xref py py-class docutils literal"><span class="pre">Session</span></tt></a>.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">hooks</tt><em class="property"> = None</em></dt>
<dd><p>Event-handling hooks.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">max_redirects</tt><em class="property"> = None</em></dt>
<dd><p>Maximum number of redirects allowed. If the request exceeds this
limit, a <tt class="xref py py-class docutils literal"><span class="pre">TooManyRedirects</span></tt> exception is raised.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">mount</tt><big>(</big><em>prefix</em>, <em>adapter</em><big>)</big></dt>
<dd><p>Registers a connection adapter to a prefix.</p>
<p>Adapters are sorted in descending order by key length.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">options</tt><big>(</big><em>url</em>, <em>**kwargs</em><big>)</big></dt>
<dd><p>Sends a OPTIONS request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">params</tt><em class="property"> = None</em></dt>
<dd><p>Dictionary of querystring data to attach to each
<a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>. The dictionary values may be lists for
representing multivalued query parameters.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">patch</tt><big>(</big><em>url</em>, <em>data=None</em>, <em>**kwargs</em><big>)</big></dt>
<dd><p>Sends a PATCH request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>data</strong> – (optional) Dictionary, bytes, or file-like object to send in the body of the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">post</tt><big>(</big><em>url</em>, <em>data=None</em>, <em>**kwargs</em><big>)</big></dt>
<dd><p>Sends a POST request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>data</strong> – (optional) Dictionary, bytes, or file-like object to send in the body of the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">prepare_request</tt><big>(</big><em>request</em><big>)</big></dt>
<dd><p>Constructs a <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> for
transmission and returns it. The <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> has settings
merged from the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> instance and those of the
<a class="reference internal" href="#requests.Session" title="requests.Session"><tt class="xref py py-class docutils literal"><span class="pre">Session</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>request</strong> – <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> instance to prepare with this
session’s settings.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">proxies</tt><em class="property"> = None</em></dt>
<dd><p>Dictionary mapping protocol to the URL of the proxy (e.g.
{‘http’: ‘foo.bar:3128’}) to be used on each
<a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">put</tt><big>(</big><em>url</em>, <em>data=None</em>, <em>**kwargs</em><big>)</big></dt>
<dd><p>Sends a PUT request. Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>data</strong> – (optional) Dictionary, bytes, or file-like object to send in the body of the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>**kwargs</strong> – Optional arguments that <tt class="docutils literal"><span class="pre">request</span></tt> takes.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">rebuild_auth</tt><big>(</big><em>prepared_request</em>, <em>response</em><big>)</big></dt>
<dd><p>When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">rebuild_proxies</tt><big>(</big><em>prepared_request</em>, <em>proxies</em><big>)</big></dt>
<dd><p>This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in case they were stripped by a previous
redirect).</p>
<p>This method also replaces the Proxy-Authorization header where
necessary.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">request</tt><big>(</big><em>method</em>, <em>url</em>, <em>params=None</em>, <em>data=None</em>, <em>headers=None</em>, <em>cookies=None</em>, <em>files=None</em>, <em>auth=None</em>, <em>timeout=None</em>, <em>allow_redirects=True</em>, <em>proxies=None</em>, <em>hooks=None</em>, <em>stream=None</em>, <em>verify=None</em>, <em>cert=None</em><big>)</big></dt>
<dd><p>Constructs a <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>, prepares it and sends it.
Returns <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>method</strong> – method for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>url</strong> – URL for the new <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a> object.</li>
<li><strong>params</strong> – (optional) Dictionary or bytes to be sent in the query
string for the <a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>data</strong> – (optional) Dictionary or bytes to send in the body of the
<a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>headers</strong> – (optional) Dictionary of HTTP Headers to send with the
<a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>cookies</strong> – (optional) Dict or CookieJar object to send with the
<a class="reference internal" href="#requests.Request" title="requests.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>files</strong> – (optional) Dictionary of ‘filename’: file-like-objects
for multipart encoding upload.</li>
<li><strong>auth</strong> – (optional) Auth tuple or callable to enable
Basic/Digest/Custom HTTP Auth.</li>
<li><strong>timeout</strong> – (optional) Float describing the timeout of the
request in seconds.</li>
<li><strong>allow_redirects</strong> – (optional) Boolean. Set to True by default.</li>
<li><strong>proxies</strong> – (optional) Dictionary mapping protocol to the URL of
the proxy.</li>
<li><strong>stream</strong> – (optional) whether to immediately download the response
content. Defaults to <tt class="docutils literal"><span class="pre">False</span></tt>.</li>
<li><strong>verify</strong> – (optional) if <tt class="docutils literal"><span class="pre">True</span></tt>, the SSL cert will be verified.
A CA_BUNDLE path can also be provided.</li>
<li><strong>cert</strong> – (optional) if String, path to ssl client cert file (.pem).
If Tuple, (‘cert’, ‘key’) pair.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">resolve_redirects</tt><big>(</big><em>resp</em>, <em>req</em>, <em>stream=False</em>, <em>timeout=None</em>, <em>verify=True</em>, <em>cert=None</em>, <em>proxies=None</em><big>)</big></dt>
<dd><p>Receives a Response. Returns a generator of Responses.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">send</tt><big>(</big><em>request</em>, <em>**kwargs</em><big>)</big></dt>
<dd><p>Send a given PreparedRequest.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">stream</tt><em class="property"> = None</em></dt>
<dd><p>Stream response content default.</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">trust_env</tt><em class="property"> = None</em></dt>
<dd><p>Should we trust the environment?</p>
</dd></dl>
<dl class="attribute">
<dt>
<tt class="descname">verify</tt><em class="property"> = None</em></dt>
<dd><p>SSL Verification default.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt>
<em class="property">class </em><tt class="descclassname">requests.adapters.</tt><tt class="descname">HTTPAdapter</tt><big>(</big><em>pool_connections=10</em>, <em>pool_maxsize=10</em>, <em>max_retries=0</em>, <em>pool_block=False</em><big>)</big></dt>
<dd><p>The built-in HTTP Adapter for urllib3.</p>
<p>Provides a general-case interface for Requests sessions to contact HTTP and
HTTPS urls by implementing the Transport Adapter interface. This class will
usually be created by the <a class="reference internal" href="#requests.Session" title="requests.Session"><tt class="xref py py-class docutils literal"><span class="pre">Session</span></tt></a> class under the
covers.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>pool_connections</strong> – The number of urllib3 connection pools to cache.</li>
<li><strong>pool_maxsize</strong> – The maximum number of connections to save in the pool.</li>
<li><strong>max_retries</strong> (<em>int</em>) – The maximum number of retries each connection
should attempt. Note, this applies only to failed connections and
timeouts, never to requests where the server returns a response.</li>
<li><strong>pool_block</strong> – Whether the connection pool should block for connections.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Usage:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">requests</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">Session</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">adapters</span><span class="o">.</span><span class="n">HTTPAdapter</span><span class="p">(</span><span class="n">max_retries</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">mount</span><span class="p">(</span><span class="s">'http://'</span><span class="p">,</span> <span class="n">a</span><span class="p">)</span>
</pre></div>
</div>
<dl class="method">
<dt>
<tt class="descname">add_headers</tt><big>(</big><em>request</em>, <em>**kwargs</em><big>)</big></dt>
<dd><p>Add any headers needed by the connection. As of v2.0 this does
nothing by default, but is left for overriding by users that subclass
the <a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a>.</p>
<p>This should not be called from user code, and is only exposed for use
when subclassing the
<a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>request</strong> – The <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> to add headers to.</li>
<li><strong>kwargs</strong> – The keyword arguments from the call to send().</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">build_response</tt><big>(</big><em>req</em>, <em>resp</em><big>)</big></dt>
<dd><p>Builds a <a class="reference internal" href="#requests.Response" title="requests.Response"><tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt></a> object from a urllib3
response. This should not be called from user code, and is only exposed
for use when subclassing the
<a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>req</strong> – The <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> used to generate the response.</li>
<li><strong>resp</strong> – The urllib3 response object.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">cert_verify</tt><big>(</big><em>conn</em>, <em>url</em>, <em>verify</em>, <em>cert</em><big>)</big></dt>
<dd><p>Verify a SSL certificate. This method should not be called from user
code, and is only exposed for use when subclassing the
<a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>conn</strong> – The urllib3 connection object associated with the cert.</li>
<li><strong>url</strong> – The requested URL.</li>
<li><strong>verify</strong> – Whether we should actually verify the certificate.</li>
<li><strong>cert</strong> – The SSL certificate to verify.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">close</tt><big>(</big><big>)</big></dt>
<dd><p>Disposes of any internal state.</p>
<p>Currently, this just closes the PoolManager, which closes pooled
connections.</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">get_connection</tt><big>(</big><em>url</em>, <em>proxies=None</em><big>)</big></dt>
<dd><p>Returns a urllib3 connection for the given URL. This should not be
called from user code, and is only exposed for use when subclassing the
<a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> – The URL to connect to.</li>
<li><strong>proxies</strong> – (optional) A Requests-style dictionary of proxies used on this request.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">init_poolmanager</tt><big>(</big><em>connections</em>, <em>maxsize</em>, <em>block=False</em><big>)</big></dt>
<dd><p>Initializes a urllib3 PoolManager. This method should not be called
from user code, and is only exposed for use when subclassing the
<a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>connections</strong> – The number of urllib3 connection pools to cache.</li>
<li><strong>maxsize</strong> – The maximum number of connections to save in the pool.</li>
<li><strong>block</strong> – Block when no free connections are available.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">proxy_headers</tt><big>(</big><em>proxy</em><big>)</big></dt>
<dd><p>Returns a dictionary of the headers to add to any request sent
through a proxy. This works with urllib3 magic to ensure that they are
correctly sent to the proxy, rather than in a tunnelled request if
CONNECT is being used.</p>
<p>This should not be called from user code, and is only exposed for use
when subclassing the
<a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>proxies</strong> – The url of the proxy being used for this request.</li>
<li><strong>kwargs</strong> – Optional additional keyword arguments.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">request_url</tt><big>(</big><em>request</em>, <em>proxies</em><big>)</big></dt>
<dd><p>Obtain the url to use when making the final request.</p>
<p>If the message is being sent through a HTTP proxy, the full URL has to
be used. Otherwise, we should only use the path portion of the URL.</p>
<p>This should not be called from user code, and is only exposed for use
when subclassing the
<a class="reference internal" href="#requests.adapters.HTTPAdapter" title="requests.adapters.HTTPAdapter"><tt class="xref py py-class docutils literal"><span class="pre">HTTPAdapter</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>request</strong> – The <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> being sent.</li>
<li><strong>proxies</strong> – A dictionary of schemes to proxy URLs.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">send</tt><big>(</big><em>request</em>, <em>stream=False</em>, <em>timeout=None</em>, <em>verify=True</em>, <em>cert=None</em>, <em>proxies=None</em><big>)</big></dt>
<dd><p>Sends PreparedRequest object. Returns Response object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"></col>
<col class="field-body"></col>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>request</strong> – The <a class="reference internal" href="#requests.PreparedRequest" title="requests.PreparedRequest"><tt class="xref py py-class docutils literal"><span class="pre">PreparedRequest</span></tt></a> being sent.</li>
<li><strong>stream</strong> – (optional) Whether to stream the request content.</li>
<li><strong>timeout</strong> – (optional) The timeout on the request.</li>
<li><strong>verify</strong> – (optional) Whether to verify SSL certificates.</li>
<li><strong>cert</strong> – (optional) Any user-provided SSL certificate to be trusted.</li>
<li><strong>proxies</strong> – (optional) The proxies dictionary to apply to the request.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
</div>
<div class="section" id="migrating-to-1-x">
<h2>Migrating to 1.x<a class="headerlink" href="#migrating-to-1-x" title="Permalink to this headline">¶</a></h2>
<p>This section details the main differences between 0.x and 1.x and is meant
to ease the pain of upgrading.</p>
<div class="section" id="api-changes">
<h3>API Changes<a class="headerlink" href="#api-changes" title="Permalink to this headline">¶</a></h3>
<ul>
<li><p class="first"><tt class="docutils literal"><span class="pre">Response.json</span></tt> is now a callable and not a property of a response.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">requests</span>
<span class="n">r</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'https://github.com/timeline.json'</span><span class="p">)</span>
<span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>   <span class="c"># This *call* raises an exception if JSON decoding fails</span>
</pre></div>
</div>
</li>
<li><p class="first">The <tt class="docutils literal"><span class="pre">Session</span></tt> API has changed. Sessions objects no longer take parameters.
<tt class="docutils literal"><span class="pre">Session</span></tt> is also now capitalized, but it can still be
instantiated with a lowercase <tt class="docutils literal"><span class="pre">session</span></tt> for backwards compatibility.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">s</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">Session</span><span class="p">()</span>    <span class="c"># formerly, session took parameters</span>
<span class="n">s</span><span class="o">.</span><span class="n">auth</span> <span class="o">=</span> <span class="n">auth</span>
<span class="n">s</span><span class="o">.</span><span class="n">headers</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">headers</span><span class="p">)</span>
<span class="n">r</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'http://httpbin.org/headers'</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p class="first">All request hooks have been removed except ‘response’.</p>
</li>
<li><p class="first">Authentication helpers have been broken out into separate modules. See
<a class="reference external" href="https://github.com/requests/requests-oauthlib">requests-oauthlib</a> and <a class="reference external" href="https://github.com/requests/requests-kerberos">requests-kerberos</a>.</p>
</li>
</ul>
<ul>
<li><p class="first">The parameter for streaming requests was changed from <tt class="docutils literal"><span class="pre">prefetch</span></tt> to
<tt class="docutils literal"><span class="pre">stream</span></tt> and the logic was inverted. In addition, <tt class="docutils literal"><span class="pre">stream</span></tt> is now
required for raw response reading.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># in 0.x, passing prefetch=False would accomplish the same thing</span>
<span class="n">r</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'https://github.com/timeline.json'</span><span class="p">,</span> <span class="n">stream</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="k">for</span> <span class="n">chunk</span> <span class="ow">in</span> <span class="n">r</span><span class="o">.</span><span class="n">iter_content</span><span class="p">(</span><span class="mi">8192</span><span class="p">):</span>
    <span class="o">...</span>
</pre></div>
</div>
</li>
<li><p class="first">The <tt class="docutils literal"><span class="pre">config</span></tt> parameter to the requests method has been removed. Some of
these options are now configured on a <tt class="docutils literal"><span class="pre">Session</span></tt> such as keep-alive and
maximum number of redirects. The verbosity option should be handled by
configuring logging.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">requests</span>
<span class="kn">import</span> <span class="nn">logging</span>

<span class="c"># these two lines enable debugging at httplib level (requests-&gt;urllib3-&gt;httplib)</span>
<span class="c"># you will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.</span>
<span class="c"># the only thing missing will be the response.body which is not logged.</span>
<span class="kn">import</span> <span class="nn">httplib</span>
<span class="n">httplib</span><span class="o">.</span><span class="n">HTTPConnection</span><span class="o">.</span><span class="n">debuglevel</span> <span class="o">=</span> <span class="mi">1</span>

<span class="n">logging</span><span class="o">.</span><span class="n">basicConfig</span><span class="p">()</span> <span class="c"># you need to initialize logging, otherwise you will not see anything from requests</span>
<span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">()</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">)</span>
<span class="n">requests_log</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s">"requests.packages.urllib3"</span><span class="p">)</span>
<span class="n">requests_log</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">)</span>
<span class="n">requests_log</span><span class="o">.</span><span class="n">propagate</span> <span class="o">=</span> <span class="bp">True</span>

<span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'http://httpbin.org/headers'</span><span class="p">)</span>
</pre></div>
</div>
</li>
</ul>
</div>
<div class="section" id="licensing">
<h3>Licensing<a class="headerlink" href="#licensing" title="Permalink to this headline">¶</a></h3>
<p>One key difference that has nothing to do with the API is a change in the
license from the <a class="reference external" href="http://opensource.org/licenses/ISC">ISC</a> license to the <a class="reference external" href="http://opensource.org/licenses/Apache-2.0">Apache 2.0</a> license. The Apache 2.0
license ensures that contributions to Requests are also covered by the Apache
2.0 license.</p>
</div>
</div>
<div class="section" id="migrating-to-2-x">
<h2>Migrating to 2.x<a class="headerlink" href="#migrating-to-2-x" title="Permalink to this headline">¶</a></h2>
<p>Compared with the 1.0 release, there were relatively few backwards
incompatible changes, but there are still a few issues to be aware of with
this major release.</p>
<p>For more details on the changes in this release including new APIs, links
to the relevant GitHub issues and some of the bug fixes, read Cory’s <a class="reference external" href="http://lukasa.co.uk/2013/09/Requests_20/">blog</a>
on the subject.</p>
<div class="section" id="id1">
<h3>API Changes<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
<ul>
<li><p class="first">There were a couple changes to how Requests handles exceptions.
<tt class="docutils literal"><span class="pre">RequestException</span></tt> is now a subclass of <tt class="docutils literal"><span class="pre">IOError</span></tt> rather than
<tt class="docutils literal"><span class="pre">RuntimeError</span></tt> as that more accurately categorizes the type of error.
In addition, an invalid URL escape sequence now raises a subclass of
<tt class="docutils literal"><span class="pre">RequestException</span></tt> rather than a <tt class="docutils literal"><span class="pre">ValueError</span></tt>.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'http://%zz/'</span><span class="p">)</span>   <span class="c"># raises requests.exceptions.InvalidURL</span>
</pre></div>
</div>
<p>Lastly, <tt class="docutils literal"><span class="pre">httplib.IncompleteRead</span></tt> exceptions caused by incorrect chunked
encoding will now raise a Requests <tt class="docutils literal"><span class="pre">ChunkedEncodingError</span></tt> instead.</p>
</li>
<li><p class="first">The proxy API has changed slightly. The scheme for a proxy URL is now
required.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">proxies</span> <span class="o">=</span> <span class="p">{</span>
  <span class="s">"http"</span><span class="p">:</span> <span class="s">"10.10.1.10:3128"</span><span class="p">,</span>    <span class="c"># use http://10.10.1.10:3128 instead</span>
<span class="p">}</span>

<span class="c"># In requests 1.x, this was legal, in requests 2.x,</span>
<span class="c">#  this raises requests.exceptions.MissingSchema</span>
<span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">"http://example.org"</span><span class="p">,</span> <span class="n">proxies</span><span class="o">=</span><span class="n">proxies</span><span class="p">)</span>
</pre></div>
</div>
</li>
</ul>
</div>
<div class="section" id="behavioural-changes">
<h3>Behavioural Changes<a class="headerlink" href="#behavioural-changes" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>Keys in the <tt class="docutils literal"><span class="pre">headers</span></tt> dictionary are now native strings on all Python
versions, i.e. bytestrings on Python 2 and unicode on Python 3. If the
keys are not native strings (unicode on Python2 or bytestrings on Python 3)
they will be converted to the native string type assuming UTF-8 encoding.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper"><p class="logo">
<a href="index.html">
<img class="logo" src="_static/requests-sidebar.png" title="Rezzy the Requests Sea Turtle"/>
</a>
</p>
<p>
<iframe allowtransparency="true" frameborder="0" height="35px" scrolling="0" src="http://ghbtns.com/github-btn.html?user=kennethreitz&amp;repo=requests&amp;type=watch&amp;count=true&amp;size=large" width="200px"></iframe>
</p>
<p>
  Requests is an elegant and simple HTTP library for Python, built for
  human beings. You are currently looking at the documentation of the
  development release.
</p>
<h3>Donate</h3>
<p>
     If you love Requests, consider supporting the author <a href="https://www.gittip.com/kennethreitz/">on Gittip</a>:
 </p>
<p>
<iframe height="20pt" src="https://www.gittip.com/kennethreitz/widget.html" style="border: 0; margin: 0; padding: 0;" width="48pt"></iframe>
</p>
<h3>Get Updates</h3>
<p>Receive updates on new releases and upcoming projects.</p>
<p><a href="http://tinyletter.com/kennethreitz">Subscribe to Newsletter</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Developer Interface</a><ul>
<li><a class="reference internal" href="#main-interface">Main Interface</a><ul>
<li><a class="reference internal" href="#lower-level-classes">Lower-Level Classes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#request-sessions">Request Sessions</a></li>
<li><a class="reference internal" href="#authentication">Authentication</a><ul>
<li><a class="reference internal" href="#exceptions">Exceptions</a></li>
<li><a class="reference internal" href="#status-code-lookup">Status Code Lookup</a></li>
<li><a class="reference internal" href="#cookies">Cookies</a></li>
<li><a class="reference internal" href="#encodings">Encodings</a></li>
<li><a class="reference internal" href="#classes">Classes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#migrating-to-1-x">Migrating to 1.x</a><ul>
<li><a class="reference internal" href="#api-changes">API Changes</a></li>
<li><a class="reference internal" href="#licensing">Licensing</a></li>
</ul>
</li>
<li><a class="reference internal" href="#migrating-to-2-x">Migrating to 2.x</a><ul>
<li><a class="reference internal" href="#id1">API Changes</a></li>
<li><a class="reference internal" href="#behavioural-changes">Behavioural Changes</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li>Previous: <a href="community/updates.html" title="previous chapter">Community Updates</a></li>
<li>Next: <a href="dev/philosophy.html" title="next chapter">Development Philosophy</a></li>
</ul></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form action="search.html" class="search" method="get">
<input name="q" type="text"/>
<input type="submit" value="Go"/>
<input name="check_keywords" type="hidden" value="yes"/>
<input name="area" type="hidden" value="default"/>
</form>
<p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
      © Copyright 2014. A <a href="http://kennethreitz.com/pages/open-projects.html">Kenneth Reitz</a> Project.
    </div>
<a class="github" href="https://github.com/kennethreitz/requests">
<img alt="Fork me on GitHub" class="github" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" style="position: absolute; top: 0; right: 0; border: 0;"/>
</a>
<script type="text/javascript">
    /* <![CDATA[ */
        (function() {
            var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];
            s.type = 'text/javascript';
            s.async = true;
            s.src = 'http://api.flattr.com/js/0.6/load.js?mode=auto';
            t.parentNode.insertBefore(s, t);
        })();
    /* ]]> */
    </script>
<script type="text/javascript">
    setTimeout(function(){var a=document.createElement("script");
    var b=document.getElementsByTagName("script")[0];
    a.src=document.location.protocol+"//dnn506yrbagrg.cloudfront.net/pages/scripts/0013/7219.js?"+Math.floor(new Date().getTime()/3600000);
    a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);
    </script>
<script type="text/javascript">
        new HelloBar(36402,48802);
    </script>
<script type="text/javascript">

      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-8742933-11']);
      _gaq.push(['_setDomainName', 'none']);
      _gaq.push(['_setAllowLinker', true]);
      _gaq.push(['_trackPageview']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();

    </script>
<script type="text/javascript">
      (function() {
        var t   = document.createElement('script');
        t.type  = 'text/javascript';
        t.async = true;
        t.id    = 'gauges-tracker';
        t.setAttribute('data-site-id',
                       '4ddc27f6613f5d186d000007');
        t.src = '//secure.gaug.es/track.js';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(t, s);
      })();
    </script>
</body>
</html>